
local meta = FindMetaTable( "Player" );

donatorlist = { }

function meta:IsDonator()

	for k, v in pairs( donatorlist ) do
	
		if( self:SteamID() == v ) then	
		
			return true
			
		end

	end	

	return false
	
end	

function meta:CanToolThis( ent, mode )

	if( ent:GetClass() == "ts2_attachment" or
		ent:GetClass() == "ts2_pickup" ) then
		
		return false;
		
	end
	
	if( ent:GetClass() == "ts2_item" ) then
	
		if( ent:GetTable().PickupParent and ent:GetTable().PickupParent:IsValid() ) then
		
			return false;
		
		end
	
	end
	
	if( ent:GetClass() == "prop_ragdoll" and ent:GetTable().IsPlayerRagdoll ) then
	
		return false;
	
	end

	--If Rick made this, only Rick can destroy this
	if( ent:GetTable().CreatorIsRick and
		not self:IsAwesome() ) then
	
		return false;
	
	end

	--If the player is either an admin or Rick, true
	if( self:IsAdmin() or self:IsAwesome() ) then
		return true;
	
	end
	
	--No duplicator!
	if( string.find( string.lower( mode ), "duplicator" ) and
		not self:GetTable().CanUseDuplicator ) then
	
		return false;
	
	end
	
	--No adv duplicator!
	if( string.find( string.lower( mode ), "adv_duplicator" ) and
		not self:GetTable().CanUseDuplicator ) then
	
		return false;
	
	end
	
	--cant use PAC tool if not donator
	if( string.find( string.lower( mode ), "pac" ) and not self:IsDonator() ) then
	
		return false
		
	end	
	
	--If the creator is tooling this, true
	if( ent:GetTable().Creator == self ) then
	
		return true;
	
	end
	
	--If the player has advanced TT, and the creator isnt a super admin or Rick, return if it can phys gun pickup
	if( self:HasTT() and 
		 ( not ent:GetTable().CreatorIsSuperAdmin and
		   not ent:GetTable().CreatorIsRick ) ) then
		
		return self:CanPhysGunPickup( ent );
		
	end
	
	--If it's an item and the player has TT and it's not duplicator, true
	if( ent:GetClass() == "ts2_item" and
		self:HasTT() and mode ~= "duplicator" ) then
		
		return true;
		
	end
	
	
	--If the player doesn't have any TT, return if he can physgun it
	if( not ent:GetTable().CreatorHasTT ) then
	
		return self:CanPhysGunPickup( ent );
	
	end
	
	--If the creator had basic TT and the tooling player has TT
	if( ent:GetTable().CreatorHasTT and self:HasTT() ) then
		
		return true;
		
	end
	
	return false;

end


local CantPhysGun =
{

	"func_door",
	"prop_ragdoll",
	"func_door_rotating",
	"prop_door_rotating",
	"func_breakable",
	"func_brush",
	"func_tracktrain",
	"func_physbox",
	"player",
	"prop_vehicle_jeep",
	"func_breakable_surf",
	"prop_vehicle_jeep_old",
	"prop_vehicle_airboat",
	"func_movelinear",
	"prop_dynamic",
	"func_monitor",
	"prop_ragdoll",

};

function meta:CanPhysGunPickup( ent )
	
	if( self:IsAdmin() or self:IsAwesome() and ent:IsPlayer() or
		ent:GetClass() == "prop_vehicle_jeep" or
		ent:GetClass() == "prop_vehicle_jeep_old" or
		ent:GetClass() == "prop_vehicle_airboat" or 
		ent:GetClass() == "prop_ragdoll" ) then
	
		return true;
	
	end
	
	if( string.find( ent:GetClass(), "npc_" ) and not self:IsAdmin() ) then return false; end
	
	for k, v in pairs( CantPhysGun ) do
	
		if( ent:GetClass() == v ) then
			return false;
		end
	
	end
	
	return true;

end

function meta:HasTT()
	
	if( self:GetTable().AdvancedTT == true or self:GetTable().BasicTT ) then
	
		return true
		
	end	
	
	return false;

end

function meta:IsTied()

	return self:GetTable().IsTied;

end

local meta = FindMetaTable( "Entity" );

local BannedModels =
{
	
	"models\props_c17\oildrum001_explosive.mdl",
	"models\props_junk\gascan001a.mdl",
	"models\props_junk\propanecanister001a.mdl",
	"models\props_explosive\explosive_butane_can.mdl",
	"models\props_explosive\explosive_butane_can02.mdl",
	"models\props_junk\propane_tank001a.mdl",
	"models\Advisorpod_crash\Advisor_Pod_crash.mdl",
	"models\Combine_Advisor_Pod\combine_advisor_pod.mdl",
	"models\advisorpod.mdl",
	"models\extras\info_speech.mdl",
	"models/props_hive/websackHalf_b.mdl",
	"models/props_fortifications/flak38.mdl",
	"models/magnusson_teleporter.mdl",
	"models/props_explosive/explosive_butane_can02.mdl",
	"models/props_explosive/explosive_butane_can.mdl",
	"models/props_hive/websackHalf_b.mdl",
	"models/props_fortifications/hedgehog_small1_snow.mdl",
	"models/props_hive/websackceiling04.mdl",
	"models/vehicle/helicopter.mdl",
	"models/props_outland/forklift_body.mdl",
	"models/props_outland/chandelier.mdl",
	"models/combine_wall.mdl",
	"models/ep1_combine_wall.mdl",
	"models/Advisorpod_crash/Advisor_Pod_crash.mdl",
	"models/Cliffs/bridge.mdl",
	"models/Cliffs/bridge02.mdl",
	"models/Cliffs/cliff01.mdl",
	"models/Cliffs/o5cliff01.mdl",
	"models/Cliffs/o5cliff02.mdl",
	"models/Cliffs/o5cliff04.mdl",
	"models/Cliffs/o5cliff05.mdl",
	"models/map12_building2/ciron.mdl",
	"models/props_vehicles/halftrack_us1snow.mdl",
	"models/props_vehicles/jeep_us.mdl",
	"models/props_vehicles/kubelwagen_snow.mdl",
	"models/props_vehicles/lcvp_open.mdl",
	"models/props_vehicles/sherman_tank.mdl",
	"models/props_vehicles/tiger_tank.mdl",
	"models/props_vehicles/lcvp_closed.mdl",
	"models/props_vehicles/sherman_tank_destroyed.mdl",
	"models/props_vehicles/sherman_tank_snow.mdl",
	"models/props_vehicles/tiger_tank_snow.mdl",
	"models/props_vehicles/tiger_tank_snow_wrecked1.mdl",
	"models/map12_building2/brushwood.mdl",
	"models/map1_bridge/bridgeDamageLeft.mdl",
	"models/mini_borealis/mini_borealis.mdl",
	"models/props_radiostation/radio_antenna01.mdl",
	"models/props_silo/rocket_low.mdl",
	"models/seesawBridge/bridge_static_exit.mdl",
	"models/seesawBridge/bridge_standin.mdl",
	"models/\props/de_inferno/archroofb.mdl",
	"models/props/de_inferno/archroofb.mdl"

}

function IsBannedModel( mdl )

	mdl = string.gsub( mdl, "/", "\\" );

	for k, v in pairs( BannedModels ) do

		if( v == string.gsub( mdl, "\\", "" ) ) then
			return true;
		end
	
	end
	
	return false;

end

function meta:IsBannedProp()

	if( IsBannedModel( self:GetModel() ) ) then return true; end
	
	return false;

end



